# while True:
#       try:
#             x = int(input("请输入一个数字："))
#             break
#       except ValueError:
#             print("您输入的不是数字，请再次尝试输入！")

# import sys

# try:
#       f = open('myfile.txt')
#       s = f.readline()
#       i = int(s.strip())
# except OSError as err:
#       print("OS error: {0}".format(err))
# except ValueError:
#       print("could not convert data to an integer.")
# except:
#       print("Unexpected error:",sys.exc_info()[0])
#       raise

# import sys

# for arg in sys.argv[1:]:
#       try:
#             f = open(arg,'r')
#       except IOError:
#             print("counnt open",arg)
#       else:
#             print(arg,'has',len(f.readlines()),'lines')
#             f.close()

# try:
#       f = open('1234.txt','r')
# except AssertionError as error:
#       print(error)
# else:
#       try:
#             with open('file.log') as file:
#                   read_data = file.read()
#       except FileNotFoundError as fnf_error:
#             print(fnf_error)
# finally:
#       print("无论异常是否发生都会执行。")

# x = 10
# if x > 5:
#       raise Exception('x 不能大于5.x 的值为：{}'.format(x))

# try:
#       raise NameError('HiThere')
# except NameError:
#       print('An exception flew by!')
#       raise

class MyError(Exception):
      def __init__(self,value):
            self.value = value

      def __str__(self):
            return repr(self.value)
      
try:
      raise MyError(2*2)
except MyError as e:
      print('My exception occurred,value:',e.value)